//通办清单梳理的js api
import request from "@/utils/request";

/**
 * 保存清单数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 查询清单列表分页数据
 * @param {*} params
 */
export function queryPages(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/handleDetailList/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 更具id查询清单数据对象
 * @param {*} id
 */
export function getById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

export function getByhdlOid(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/getByhdlOid?hdlOid=` +
      hdlOid,
    method: "get",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 切换清单状态
 * @param {*} id
 * @param {*} stateFlag
 */
export function updateStateFlag(id, stateFlag) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/updateStateFlag",
    method: "get",
    params: {
      id,
      stateFlag
    }
  });
}

/**
 * 通过主键删除区域数据
 * @param {*} id
 */
export function deleteHandleDetailListById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/deleteHandleDetailListById",
    method: "get",
    params: {
      id
    }
  });
}

/**
 * 清单上架前的校验
 * @param {*} hdlOid
 */
export function checkPutOnTheShelves(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/checkPutOnTheShelves/${hdlOid}`,

    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 上架操作
 * @param {*} id
 * @param {*} applyTypeCodes
 */
export function groundingDetailList(id, applyTypeCodes) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/groundingDetailList",
    method: "get",
    params: {
      id,
      applyTypeCodes
    }
  });
}

/**
 * 根据DistrictOid 查询事项集合数据
 * @param {*} districtOid
 */
/*export function querySxServiceListByDistrictOid(districtOid) {
  return request({
    url:
      process.env.VUE_APP_SX_ROUTE_PATH +
      "/affair/sxService/getSxServicListByDistrictOid",
    method: "get",
    params: {
      districtOid: districtOid
    }
  });
}*/

/**
 * 根据DistrictOid 查询事项集合数据
 * @param {*} districtOid
 */
export function querySxServiceListByCityCode(cityCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdService/querySxServiceListByCityCode",
    method: "get",
    params: {
      cityCode: cityCode
    }
  });
}

/**
 * 查询所有的清单数据
 */
export function queryAllDetailList(preHdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/querySelectPreposeList/${preHdlOid}`,
    method: "post"
  });
}

/**
 * 保存或更新配置的清单前置清单数据
 * @param {*} data
 */
export function saveOrUpdateDetailListPrepose(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/detailListPrepose/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据HDLOid查询前置清单数据
 * @param {*} hdlOid
 */
export function queryDetailListPreposeByHdlOid(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/detailListPrepose/queryDetailListPreposeByHdlOid/${hdlOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据id查询清单是否是其他清单的前置清单
 * @param {*} id
 * @returns
 */
export function hasHandleDetailListPrepose(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/hasHandleDetailListPrepose/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 校验清单编码是否存在 存在返回true，不存在返回false
 * @param {*} detailListCode
 */
export function checkDetailListCode(detailListCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/handleDetailList/checkDetailListCode/${detailListCode}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
